# -*- coding: utf-8 -*-
# @File:     send_mail.py
# @Author:
# @DateTime: 2025/06/25/13:37

import smtplib
from email.mime.text import MIMEText
from email.header import Header


def send_mail_msg(subject, body, sender, reciver, smtp_server, smtp_port, password):
    msg = MIMEText(body, 'plain', 'utf-8')
    msg['From'] = Header(sender)
    msg['To'] = Header(reciver)
    msg['Subject'] = Header(subject)

    try:
        server = smtplib.SMTP_SSL(smtp_server, smtp_port)  # 使用SSL连接
        server.login(sender, password)
        server.sendmail(sender, reciver, msg.as_string())
        server.quit()
        return True, None
    except Exception as e:
        return False, e
        # print(f"发送失败：{e}")



